package cn.itcast.ssm.controller.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Description: convert of string 2 date.
 * Created by t410 on 2017/7/3.
 */
public class CustomDateConverter implements Converter<String ,Date> {

    @Override
    public Date convert(String dateString){
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
        Date date= null;
        try {
            date = simpleDateFormat.parse(dateString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}
